﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Services;
using System.Web.Script.Services;
using Newtonsoft.Json;
using System.IO;
using System.Web.UI.HtmlControls;

namespace PromotionEngine
{
    public partial class ReportHeader : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public static string GetAllReports()
        {
            Promotion pmt = new Promotion();
            DataSet dsPromotion = pmt.GetAllUserDefinedReport(ConfigurationManager.AppSettings["DATABASE_NAME"].ToString(), HttpContext.Current.Session["CompanyCode"].ToString());
            if (dsPromotion != null)
            {
                return JsonConvert.SerializeObject(dsPromotion.Tables[0]);
            }
            return string.Empty;
        }
        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public static void DeleteReport(string reportID)
        {
            Promotion pmt = new Promotion();
            string errMsg = pmt.DeleteReport(ConfigurationManager.AppSettings["DATABASE_NAME"].ToString(), reportID);
            if (errMsg.Length == 0)
            {
                //Show error message
            }
        }
    }
}